<template>
    <div class='newsInfo-container'>
        <h3 class='title'>{{newsinfo.title}}</h3>
        <p class='sub'>
            <span>发表时间:{{newsinfo.add_time |dateFormat('YYYY-MM-DD hh:mm:ss')}}</span>
            <span>点击次数:{{newsinfo.click}}</span>
        </p>
        <hr>
        <div class="content" v-html='newsinfo.content'></div>
        <!-- 评论组件 -->
        <content-box :id='this.id'></content-box>
    </div>
</template>

<script>
// 导入评论组件
import comment from '../suncomponents/comment.vue'

import { Toast } from "mint-ui";
export default{

    data(){
        return {
            id:this.$route.params.id,
            newsinfo:{}
        }
    },
    created(){
        this.getNewsInfo()
    },
    methods: {
        getNewsInfo(){
            this.$http.get('api/getnew/'+this.id).then(result=>{
                if(result.body.status===0){
                    // console.log(result.body)
                    // console.log(123);
                    this.newsinfo=result.body.message[0]
                }else{
                    Toast('获取新闻列表失败')
                }
            })
            console.log(this)
        }
    },
    components:{
        "content-box":comment
    }

}
</script>

<style lang='scss'>
.newsInfo-container{
    padding:0 4px;
    .title{
        font-size: 16px;
        text-align: center;
        margin:15px 0;
        color:red;
    }
    .sub{
        display: flex;
        color:blue;
        font-size: 14px;
        justify-content: space-between;
    }
    .content{
        img{
            width: 100%;
        }
    }
}
</style>
